-
Notifications
You must be signed in to change notification settings - Fork 72
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added support for json functions #546
base: main
Are you sure you want to change the base?
Conversation
sql/pg_duckdb--0.2.0--0.3.0.sql
Outdated
@@ -17,3 +17,227 @@ CREATE AGGREGATE @[email protected]_count_distinct(anyelement) | |||
|
|||
CREATE DOMAIN pg_catalog.blob AS bytea; | |||
COMMENT ON DOMAIN pg_catalog.blob IS 'The DuckDB BLOB alias for BYTEA'; | |||
|
|||
-- json_exists | |||
CREATE FUNCTION @[email protected]_exists(json VARCHAR , path VARCHAR) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems confusing that these functions expect a VARCHAR
type for the json
argument. I'd expect that argument to be of the json
or jsonb
(or have functions for both of them).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just added for json
src/pgduckdb_metadata_cache.cpp
Outdated
"iceberg_snapshots", "delta_scan", "read_json", "approx_count_distinct"}; | ||
const char *function_names[] = {"read_parquet", "read_csv", "iceberg_scan", "iceberg_metadata", | ||
"iceberg_snapshots", "delta_scan", "read_json", "approx_count_distinct", | ||
"json_exists", "json_extract", "json_extract_string"}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems this list is missing a bunch of the functions that you added.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added
@@ -0,0 +1,144 @@ | |||
-- <JSON_EXISTS> | |||
-- Test 1: Path exists in a simple JSON object | |||
SELECT json_exists('{"a": {"b": 1}}', '$.a.b'); -- Expected: true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think most of these tests simply test that DuckDB works correctly, not so much the pg_duckdb intgration.
I think for each function it should give us enough confidence into pg_duckdb to add one test with reasonable arguments, and then tests with the various combinations of NULL
arguments. So while I really appreciate the effort to add extensive tests, I don't think they add much value and would in practice only increase test runtime.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reduced the tests
@JelteF structures are not supported as types in pg_duckdb so not possible to implement functions like:
Added all the other ones |
Curious why this fails on postgres 17 |
Addresses #516